package com.order.flowserver.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;

/**
 * <br>
 *
 * @author 李恒
 * @version 1.0
 * @date: 2016/9/12 0012 下午 12:57
 */
@Configuration("ConversionConfig")
public class ConversionConfig {

	@Bean
	public MappingJackson2HttpMessageConverter httpMessageConverter() {
		MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
		// 设置null值不参与序列化(字段不被显示)
		mappingJackson2HttpMessageConverter.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
		// 禁用空对象转换json校验
		mappingJackson2HttpMessageConverter.getObjectMapper()
				.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
		mappingJackson2HttpMessageConverter.getObjectMapper()
				.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
		return mappingJackson2HttpMessageConverter;
	}

}